/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Cali.java
 *
 * Created on 10-dic-2009, 18:52:06
 */
package Vista;

import Controlador.Controlador;
import Modelo.Alertas;
import Modelo.CalculosDatos;
import Modelo.ElementoPOI;
import Modelo.GeomantesDatos;
import Modelo.Idiomas.LocaleManager;
import Modelo.ListadoPOI;
import Utils.Ficheros.FicheroDatos;
import Utils.Util;
import com.chaeron.GPS.exception.GPSException;
import java.awt.*;
import java.io.FileNotFoundException;
import java.util.Calendar;
import java.util.Vector;
import javax.swing.*;

public class GUI_NavegarGPS extends javax.swing.JDialog {

    private static Controlador controlador;
    private static JPanel mapa;
    private static Vector rutaLatLong; //Contiene FicheroDatos (para guardar las lat/long en ficheros)
    private boolean modoMarcar;
    private boolean modoGrabar;
    private int zoom;
    private double latitudClick, longitudClick;
    private double latitudDraggedAntigua, longitudDraggedAntigua;
    private FicheroDatos volverDrag;
    private FicheroDatos centro;
    private FicheroDatos centroOriginal;
    private Cursor defaultCursor;
    private boolean modoDragged; //Indica si estamos explorando el mapa (dragg)
    private DefaultListModel modelListPOI; //Lista de los POIS
    private DefaultComboBoxModel modelCBPOI; //Lista de los colores de la ruta
    private ListadoPOI poi;
    private GeomantesDatos gps;
    private Thread navegar;
    private boolean continuarGps;
    private int intervaloGps;
    private boolean anadePOI;
    private Cursor cursorAntiguo;
    private long horaMilis;

    public GUI_NavegarGPS(JFrame parent) {
        super(parent, true);
        initComponents();
        boolean errorIniciarGps = false;
        gps = new GeomantesDatos();


        //Inicializamos el gps y vemos si hay error
        try {
            gps.initGPS();
        } catch (GPSException ex) {
            ex.printStackTrace();
            errorIniciarGps = true;
        }
        //*****************************************



        //Quedo esperando a tener 1 coordenada válida
        int timeOut = 0;
        if (!errorIniciarGps) {
            try {
                gps.pollGPS();
                while (gps.getCoordenada().getLatitud() == -1 && timeOut < 2000) {
                    Thread.sleep(1000);
                    timeOut = timeOut + 1000;
                    gps.pollGPS();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        //******************************************



        //Continuo si:
        //1) No ha habido error al iniciar
        //2) La coordenada es válida
        //3) No ha habido un timeout
        if (errorIniciarGps) {
            Alertas.errorPuertoSerie(this);
            BSalirActionPerformed(null);
        } else if (gps.getCoordenada().getLatitud() == -1 || timeOut >= 6000) {
            Alertas.timeOut(this);
            BSalirActionPerformed(null);
        } else {
            inicializarValores();
            cambioIdioma();
            centrarAplicacion();
            setVisible(true);
        }
    }

    public static JPanel getDisplayMapa() {
        return mapa;
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        popup = new javax.swing.JPopupMenu();
        popupAddPOI = new javax.swing.JMenuItem();
        popupCancelar = new javax.swing.JMenuItem();
        popupCentrar = new javax.swing.JMenuItem();
        DPMapa = new javax.swing.JDesktopPane();
        PMapa = new javax.swing.JPanel();
        BVolver = new javax.swing.JButton();
        PDatos = new javax.swing.JPanel();
        LLatitud = new javax.swing.JLabel();
        TXTLatitud = new javax.swing.JTextField();
        TXTVelocidad = new javax.swing.JTextField();
        LVelocidad = new javax.swing.JLabel();
        TXTDistancia = new javax.swing.JTextField();
        LDistancia = new javax.swing.JLabel();
        TXTLongitud = new javax.swing.JTextField();
        LLongitud = new javax.swing.JLabel();
        BDetenerGps = new javax.swing.JButton();
        JTPTodo = new javax.swing.JTabbedPane();
        PTodoMapa = new javax.swing.JPanel();
        BHybrid = new javax.swing.JButton();
        BRoadmap = new javax.swing.JButton();
        BSatellite = new javax.swing.JButton();
        BTerreno = new javax.swing.JButton();
        BGuardarMapas = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JSeparator();
        LRoadmap = new javax.swing.JLabel();
        LSatelite = new javax.swing.JLabel();
        LTerreno = new javax.swing.JLabel();
        LHibrido = new javax.swing.JLabel();
        PTodoRutas = new javax.swing.JPanel();
        BCargarRuta = new javax.swing.JButton();
        BMarcarRuta = new javax.swing.JButton();
        BDeshacerMarca = new javax.swing.JButton();
        BBorrarRuta = new javax.swing.JButton();
        BGrabarRuta = new javax.swing.JButton();
        BMostrarRuta = new javax.swing.JCheckBox();
        LPintarRuta = new javax.swing.JLabel();
        LGrabarRuta = new javax.swing.JLabel();
        LColorRuta = new javax.swing.JLabel();
        CBColorRuta1 = new javax.swing.JComboBox();
        CBColorRuta2 = new javax.swing.JComboBox();
        CBColorRuta3 = new javax.swing.JComboBox();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        JLPuntosRec = new javax.swing.JLabel();
        PTodoPOI = new javax.swing.JPanel();
        TXTNombrePOI = new javax.swing.JTextField();
        LNombrePOI = new javax.swing.JLabel();
        LTipoPOI = new javax.swing.JLabel();
        LDescPOI = new javax.swing.JLabel();
        LPOI = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        TXTDescripcion = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        JListPOI = new javax.swing.JList();
        BGuardarPOI = new javax.swing.JButton();
        BBorrarPOI = new javax.swing.JButton();
        BAnadirTipoPOI = new javax.swing.JButton();
        TXTTipo = new javax.swing.JTextField();
        BMostrarPOI = new javax.swing.JCheckBox();
        BCargarPOI = new javax.swing.JButton();
        BZoomMas = new javax.swing.JButton();
        BZoomMenos = new javax.swing.JButton();
        BCargarMapa = new javax.swing.JButton();
        BSalir = new javax.swing.JButton();

        popupAddPOI.setText("Añadir POI");
        popupAddPOI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                popupAddPOIActionPerformed(evt);
            }
        });
        popup.add(popupAddPOI);

        popupCancelar.setText("Cancelar");
        popup.add(popupCancelar);

        popupCentrar.setText("Centrar aquí");
        popupCentrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                popupCentrarActionPerformed(evt);
            }
        });
        popup.add(popupCentrar);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        DPMapa.setBackground(new java.awt.Color(235, 233, 237));
        DPMapa.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), LocaleManager.getMessage("navegacionMapa"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N
        DPMapa.setForeground(new java.awt.Color(235, 233, 237));
        DPMapa.setPreferredSize(new java.awt.Dimension(650, 560));

        PMapa.setToolTipText("");
        PMapa.setName("Mapa"); // NOI18N
        PMapa.setPreferredSize(new java.awt.Dimension(633, 548));
        PMapa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                PMapaMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                PMapaMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                PMapaMouseReleased(evt);
            }
        });
        PMapa.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                PMapaMouseDragged(evt);
            }
        });

        BVolver.setForeground(java.awt.Color.red);
        BVolver.setText("Volver");
        BVolver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BVolverActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PMapaLayout = new javax.swing.GroupLayout(PMapa);
        PMapa.setLayout(PMapaLayout);
        PMapaLayout.setHorizontalGroup(
            PMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PMapaLayout.createSequentialGroup()
                .addContainerGap(570, Short.MAX_VALUE)
                .addComponent(BVolver))
        );
        PMapaLayout.setVerticalGroup(
            PMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PMapaLayout.createSequentialGroup()
                .addContainerGap(525, Short.MAX_VALUE)
                .addComponent(BVolver))
        );

        PMapa.setBounds(10, 20, 633, 548);
        DPMapa.add(PMapa, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PDatos.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Datos", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N

        LLatitud.setText("Latitud");

        TXTLatitud.setEditable(false);
        TXTLatitud.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        TXTLatitud.setText("0.0");

        TXTVelocidad.setEditable(false);
        TXTVelocidad.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        TXTVelocidad.setText("0.0");

        LVelocidad.setText("Velocidad (Km/h)");

        TXTDistancia.setEditable(false);
        TXTDistancia.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        TXTDistancia.setText("0.0");

        LDistancia.setText("Distancia (Km)");

        TXTLongitud.setEditable(false);
        TXTLongitud.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        TXTLongitud.setText("0.0");

        LLongitud.setText("Longitud");

        BDetenerGps.setForeground(java.awt.Color.red);
        BDetenerGps.setText("PARAR GPS");
        BDetenerGps.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BDetenerGpsActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PDatosLayout = new javax.swing.GroupLayout(PDatos);
        PDatos.setLayout(PDatosLayout);
        PDatosLayout.setHorizontalGroup(
            PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PDatosLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PDatosLayout.createSequentialGroup()
                        .addComponent(LLatitud, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(TXTLatitud, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(PDatosLayout.createSequentialGroup()
                        .addComponent(LLongitud, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(TXTLongitud, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(29, 29, 29)
                .addGroup(PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PDatosLayout.createSequentialGroup()
                        .addComponent(LVelocidad, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(TXTVelocidad, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(PDatosLayout.createSequentialGroup()
                        .addComponent(LDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(TXTDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
                        .addComponent(BDetenerGps))))
        );
        PDatosLayout.setVerticalGroup(
            PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PDatosLayout.createSequentialGroup()
                .addGroup(PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PDatosLayout.createSequentialGroup()
                        .addGroup(PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LVelocidad)
                            .addComponent(TXTVelocidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LDistancia)
                            .addComponent(TXTDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(PDatosLayout.createSequentialGroup()
                        .addGroup(PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LLatitud)
                            .addComponent(TXTLatitud, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(PDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LLongitud)
                            .addComponent(TXTLongitud, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PDatosLayout.createSequentialGroup()
                .addContainerGap(48, Short.MAX_VALUE)
                .addComponent(BDetenerGps))
        );

        BHybrid.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/mapaHybrid2.png"))); // NOI18N
        BHybrid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BHybridActionPerformed(evt);
            }
        });

        BRoadmap.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/mapaRoadmap2.png"))); // NOI18N
        BRoadmap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BRoadmapActionPerformed(evt);
            }
        });

        BSatellite.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/mapaSatellite2.png"))); // NOI18N
        BSatellite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSatelliteActionPerformed(evt);
            }
        });

        BTerreno.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/mapaTerrain2.png"))); // NOI18N
        BTerreno.setEnabled(false);
        BTerreno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTerrenoActionPerformed(evt);
            }
        });

        BGuardarMapas.setText("Guardar mapas");
        BGuardarMapas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BGuardarMapasActionPerformed(evt);
            }
        });

        LRoadmap.setFont(new java.awt.Font("Calibri", 0, 18));
        LRoadmap.setText("Roadmap");

        LSatelite.setFont(new java.awt.Font("Calibri", 0, 18));
        LSatelite.setText("Satellite");

        LTerreno.setFont(new java.awt.Font("Calibri", 0, 18));
        LTerreno.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        LTerreno.setText(" Terrain");

        LHibrido.setFont(new java.awt.Font("Calibri", 0, 18));
        LHibrido.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        LHibrido.setText(" Hybrid");

        javax.swing.GroupLayout PTodoMapaLayout = new javax.swing.GroupLayout(PTodoMapa);
        PTodoMapa.setLayout(PTodoMapaLayout);
        PTodoMapaLayout.setHorizontalGroup(
            PTodoMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PTodoMapaLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(PTodoMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(PTodoMapaLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(LRoadmap, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(BRoadmap, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
                .addGroup(PTodoMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BHybrid, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(PTodoMapaLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(LHibrido, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(31, 31, 31))
            .addComponent(jSeparator4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
            .addGroup(PTodoMapaLayout.createSequentialGroup()
                .addGap(85, 85, 85)
                .addComponent(BGuardarMapas)
                .addContainerGap(84, Short.MAX_VALUE))
            .addGroup(PTodoMapaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PTodoMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BSatellite, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(PTodoMapaLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(LSatelite)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
                .addGroup(PTodoMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BTerreno, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(PTodoMapaLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(LTerreno, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(29, 29, 29))
        );
        PTodoMapaLayout.setVerticalGroup(
            PTodoMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PTodoMapaLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(PTodoMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PTodoMapaLayout.createSequentialGroup()
                        .addComponent(BRoadmap)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(LRoadmap))
                    .addGroup(PTodoMapaLayout.createSequentialGroup()
                        .addComponent(BHybrid, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(LHibrido, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)))
                .addGap(34, 34, 34)
                .addGroup(PTodoMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PTodoMapaLayout.createSequentialGroup()
                        .addComponent(BSatellite)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(LSatelite))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PTodoMapaLayout.createSequentialGroup()
                        .addComponent(BTerreno)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(LTerreno)))
                .addGap(31, 31, 31)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(BGuardarMapas)
                .addGap(47, 47, 47))
        );

        JTPTodo.addTab("Mapa", PTodoMapa);

        BCargarRuta.setText("Cargar ruta");
        BCargarRuta.setActionCommand("JBCargarRuta");
        BCargarRuta.setFocusPainted(false);
        BCargarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCargarRutaActionPerformed(evt);
            }
        });

        BMarcarRuta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/marcador.png"))); // NOI18N
        BMarcarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextMarcar"));
        BMarcarRuta.setActionCommand("JBMarcarRuta");
        BMarcarRuta.setFocusPainted(false);
        BMarcarRuta.setPreferredSize(new java.awt.Dimension(40, 41));
        BMarcarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BMarcarRutaActionPerformed(evt);
            }
        });

        BDeshacerMarca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonDeshacer_naranja.png"))); // NOI18N
        BDeshacerMarca.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextDeshacer"));
        BDeshacerMarca.setEnabled(false);
        BDeshacerMarca.setFocusPainted(false);
        BDeshacerMarca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BDeshacerMarcaActionPerformed(evt);
            }
        });

        BBorrarRuta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonBorrar.png"))); // NOI18N
        BBorrarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextBorrar"));
        BBorrarRuta.setFocusPainted(false);
        BBorrarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BBorrarRutaActionPerformed(evt);
            }
        });

        BGrabarRuta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonGrabarOn.png"))); // NOI18N
        BGrabarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextRec"));
        BGrabarRuta.setActionCommand("JBGrabarRuta");
        BGrabarRuta.setFocusPainted(false);
        BGrabarRuta.setIconTextGap(0);
        BGrabarRuta.setPreferredSize(new java.awt.Dimension(60, 70));
        BGrabarRuta.setRequestFocusEnabled(false);
        BGrabarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BGrabarRutaActionPerformed(evt);
            }
        });

        BMostrarRuta.setSelected(true);
        BMostrarRuta.setText("Mostrar Ruta");
        BMostrarRuta.setEnabled(false);
        BMostrarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BMostrarRutaActionPerformed(evt);
            }
        });

        LPintarRuta.setFont(new java.awt.Font("Calibri", 0, 14));
        LPintarRuta.setText("Pintar ruta");

        LGrabarRuta.setFont(new java.awt.Font("Calibri", 0, 14));
        LGrabarRuta.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        LGrabarRuta.setText("Grabar ruta");

        LColorRuta.setFont(new java.awt.Font("Calibri", 0, 14));
        LColorRuta.setText("Colores de la ruta");

        CBColorRuta1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        CBColorRuta1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                CBColorRuta1ItemStateChanged(evt);
            }
        });

        CBColorRuta2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        CBColorRuta2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                CBColorRuta2ItemStateChanged(evt);
            }
        });

        CBColorRuta3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        CBColorRuta3.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                CBColorRuta3ItemStateChanged(evt);
            }
        });

        JLPuntosRec.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/rec_gif.gif"))); // NOI18N

        javax.swing.GroupLayout PTodoRutasLayout = new javax.swing.GroupLayout(PTodoRutas);
        PTodoRutas.setLayout(PTodoRutasLayout);
        PTodoRutasLayout.setHorizontalGroup(
            PTodoRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PTodoRutasLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(BCargarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BMostrarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(16, Short.MAX_VALUE))
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
            .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
            .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
            .addGroup(PTodoRutasLayout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addComponent(CBColorRuta1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(CBColorRuta2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(CBColorRuta3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(35, Short.MAX_VALUE))
            .addGroup(PTodoRutasLayout.createSequentialGroup()
                .addGap(91, 91, 91)
                .addComponent(LColorRuta)
                .addContainerGap(85, Short.MAX_VALUE))
            .addGroup(PTodoRutasLayout.createSequentialGroup()
                .addContainerGap(75, Short.MAX_VALUE)
                .addGroup(PTodoRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BGrabarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LGrabarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(JLPuntosRec, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(63, 63, 63))
            .addGroup(PTodoRutasLayout.createSequentialGroup()
                .addGroup(PTodoRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, PTodoRutasLayout.createSequentialGroup()
                        .addGap(98, 98, 98)
                        .addComponent(LPintarRuta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, PTodoRutasLayout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addComponent(BMarcarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(BDeshacerMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BBorrarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(39, Short.MAX_VALUE))
        );
        PTodoRutasLayout.setVerticalGroup(
            PTodoRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PTodoRutasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PTodoRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BCargarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BMostrarRuta))
                .addGap(18, 18, 18)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LPintarRuta)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PTodoRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BMarcarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BDeshacerMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BBorrarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(36, 36, 36)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PTodoRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LGrabarRuta)
                    .addComponent(JLPuntosRec, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BGrabarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LColorRuta)
                .addGap(18, 18, 18)
                .addGroup(PTodoRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CBColorRuta1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CBColorRuta2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CBColorRuta3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(40, 40, 40))
        );

        JTPTodo.addTab("Rutas", PTodoRutas);

        TXTNombrePOI.setEditable(false);
        TXTNombrePOI.setFont(new java.awt.Font("Calibri", 0, 11));

        LNombrePOI.setText("Nombre");

        LTipoPOI.setText("Tipo");

        LDescPOI.setText("Descripción");

        LPOI.setText("POIs");

        TXTDescripcion.setColumns(20);
        TXTDescripcion.setEditable(false);
        TXTDescripcion.setFont(new java.awt.Font("Calibri", 0, 13));
        TXTDescripcion.setRows(5);
        TXTDescripcion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                TXTDescripcionMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                TXTDescripcionMouseExited(evt);
            }
        });
        jScrollPane2.setViewportView(TXTDescripcion);

        JListPOI.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        JListPOI.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                JListPOIValueChanged(evt);
            }
        });
        jScrollPane3.setViewportView(JListPOI);

        BGuardarPOI.setText("Guardar");
        BGuardarPOI.setEnabled(false);
        BGuardarPOI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BGuardarPOIActionPerformed(evt);
            }
        });

        BBorrarPOI.setText("Borrar");
        BBorrarPOI.setEnabled(false);
        BBorrarPOI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BBorrarPOIActionPerformed(evt);
            }
        });

        BAnadirTipoPOI.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/punteroPOI.png"))); // NOI18N
        BAnadirTipoPOI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BAnadirTipoPOIActionPerformed(evt);
            }
        });

        TXTTipo.setEditable(false);
        TXTTipo.setFont(new java.awt.Font("Calibri", 0, 11));

        BMostrarPOI.setSelected(true);
        BMostrarPOI.setText("Mostrar POIs");
        BMostrarPOI.setEnabled(false);
        BMostrarPOI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BMostrarPOIActionPerformed(evt);
            }
        });

        BCargarPOI.setText("Cargar");
        BCargarPOI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCargarPOIActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PTodoPOILayout = new javax.swing.GroupLayout(PTodoPOI);
        PTodoPOI.setLayout(PTodoPOILayout);
        PTodoPOILayout.setHorizontalGroup(
            PTodoPOILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PTodoPOILayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PTodoPOILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LPOI)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LDescPOI)
                    .addGroup(PTodoPOILayout.createSequentialGroup()
                        .addGroup(PTodoPOILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(TXTTipo)
                            .addComponent(TXTNombrePOI)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                            .addComponent(LNombrePOI)
                            .addComponent(LTipoPOI))
                        .addGap(19, 19, 19)
                        .addGroup(PTodoPOILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(PTodoPOILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(BGuardarPOI, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(BCargarPOI, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(BBorrarPOI, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(BMostrarPOI, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BAnadirTipoPOI, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(31, 31, 31))
        );
        PTodoPOILayout.setVerticalGroup(
            PTodoPOILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PTodoPOILayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LPOI)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PTodoPOILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(PTodoPOILayout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(LNombrePOI))
                    .addGroup(PTodoPOILayout.createSequentialGroup()
                        .addComponent(BGuardarPOI)
                        .addGap(18, 18, 18)
                        .addComponent(BCargarPOI)
                        .addGap(18, 18, 18)
                        .addComponent(BBorrarPOI)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(BMostrarPOI)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PTodoPOILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(PTodoPOILayout.createSequentialGroup()
                        .addComponent(TXTNombrePOI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(LTipoPOI)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(TXTTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(17, 17, 17))
                    .addComponent(BAnadirTipoPOI, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(LDescPOI)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(45, Short.MAX_VALUE))
        );

        JTPTodo.addTab("POIs", PTodoPOI);

        BZoomMas.setFont(new java.awt.Font("Arial", 2, 12));
        BZoomMas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonZoomIn.png"))); // NOI18N
        BZoomMas.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextZoomMas"));
        BZoomMas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BZoomMasActionPerformed(evt);
            }
        });

        BZoomMenos.setFont(new java.awt.Font("Arial", 2, 12));
        BZoomMenos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonZoomOut.png"))); // NOI18N
        BZoomMenos.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextZoomMenos"));
        BZoomMenos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BZoomMenosActionPerformed(evt);
            }
        });

        BCargarMapa.setText("Cargar Mapa");
        BCargarMapa.setVisible(false);
        BCargarMapa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCargarMapaActionPerformed(evt);
            }
        });

        BSalir.setFont(new java.awt.Font("Tahoma", 0, 18));
        BSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/exit.png"))); // NOI18N
        BSalir.setText("Salir");
        BSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(DPMapa, javax.swing.GroupLayout.PREFERRED_SIZE, 649, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(PDatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(BCargarMapa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(BZoomMas, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(BZoomMenos, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(JTPTodo, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE))
                    .addComponent(BSalir, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(BZoomMas, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BZoomMenos, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JTPTodo, javax.swing.GroupLayout.PREFERRED_SIZE, 466, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(DPMapa, javax.swing.GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(BCargarMapa)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(BSalir))
                    .addComponent(PDatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BCargarMapaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCargarMapaActionPerformed
        try {
            if (controlador.cargarMapa()) {
                controlador.getGeomantes().setCoordenadas(new FicheroDatos(
                        (CalculosDatos.getLatEsqDrch() + CalculosDatos.getLatEsqIzq()) / 2,
                        (CalculosDatos.getLongEsqDrch() + CalculosDatos.getLongEsqIzq()) / 2));
                JTPTodo.setEnabled(true);
                BZoomMas.setEnabled(true);
                BZoomMenos.setEnabled(true);
                Component[] c = (Component[]) PTodoRutas.getComponents();
                for (int i = 0; i < c.length; i++) {
                    c[i].setEnabled(true);
                }
                BDetenerGps.setVisible(true);
                gps.initGPS();
                controlador.iniciarGeomantes();
                configCoordenadas();
                activarGps();
                horaMilis = Calendar.getInstance().getTimeInMillis();
                navegar();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            Alertas.falloCargarRuta(this);
        }
}//GEN-LAST:event_BCargarMapaActionPerformed

    private void BZoomMasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BZoomMasActionPerformed
        if (controlador.getModoMapas() && zoom < 19) {
            controlador.getGeomantes().setNivelZoom(controlador.getGeomantes().getNivelZoom() + 1);
            zoom++;
            if (zoom > 15) {
                BTerreno.setEnabled(false);
            }
            double nuevaEscala = dameEscala();
            CalculosDatos.setInfoGoogle(
                    controlador.getGeomantes().getCoordenadas(),
                    1899,
                    1644,
                    "WGS 84", nuevaEscala);
            controlador.getGeomantes().setEscala(nuevaEscala);
            controlador.getGeomantes().inicializarGmaps();
            if (controlador.getModoGrabacion()) {
                controlador.redibujarRuta(rutaLatLong);
            }
            if (controlador.getListadoPOI().getListaPOI().size() > 0) {
                controlador.redibujarPOI();
            }
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        }
}//GEN-LAST:event_BZoomMasActionPerformed

    private void BZoomMenosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BZoomMenosActionPerformed
        if (controlador.getModoMapas() && zoom > 15) {
            controlador.getGeomantes().setNivelZoom(controlador.getGeomantes().getNivelZoom() - 1);
            zoom--;
            if (zoom == 15) {
                BTerreno.setEnabled(true);
            }
            double nuevaEscala = dameEscala();
            CalculosDatos.setInfoGoogle(
                    controlador.getGeomantes().getCoordenadas(),
                    1899,
                    1644,
                    "WGS 84", nuevaEscala);
            controlador.getGeomantes().setEscala(nuevaEscala);
            controlador.getGeomantes().inicializarGmaps();
            if (controlador.getModoGrabacion()) {
                controlador.redibujarRuta(rutaLatLong);
            }
            if (controlador.getListadoPOI().getListaPOI().size() > 0) {
                controlador.redibujarPOI();
            }
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        }
}//GEN-LAST:event_BZoomMenosActionPerformed

    private void PMapaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMousePressed
        if (evt.isMetaDown()) {
            if (!modoDragged) {
                volverDrag = new FicheroDatos(centro.getLatitud(), centro.getLongitud());
                modoDragged = true;
                BVolver.setVisible(true);
                BDetenerGpsActionPerformed(null);
            }
            if (cursorAntiguo == null) {
                cursorAntiguo = PMapa.getCursor();
            }
            PMapa.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
            double[] latlong = dameLatLong(evt.getPoint());
            latitudDraggedAntigua = latlong[0];
            longitudDraggedAntigua = latlong[1];
            latitudDraggedAntigua = latlong[0];
            longitudDraggedAntigua = latlong[1];
            BVolver.repaint();
        }
    }//GEN-LAST:event_PMapaMousePressed

    private void PMapaMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMouseReleased
        if (evt.isMetaDown()) {
            PMapa.setCursor(cursorAntiguo);
            cursorAntiguo = null;
            controlador.getGeomantes().setCoordenadas(centro);
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            actualizarTXT();
            BVolver.repaint();
        }
    }//GEN-LAST:event_PMapaMouseReleased

    private void PMapaMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMouseDragged
        if (evt.isMetaDown()) {
            double[] latlong = dameLatLong(evt.getPoint());
            double latitud = latlong[0];
            double longitud = latlong[1];
            double restaLat = latitudDraggedAntigua - latitud;
            double restaLong = longitudDraggedAntigua - longitud;
            controlador.getGeomantes().setSumaLatLong(restaLat, restaLong);
            FicheroDatos actual = new FicheroDatos(
                    controlador.getGeomantes().getCoordenadas().getLatitud(),
                    controlador.getGeomantes().getCoordenadas().getLongitud());
            if (modoGrabar) {
                rutaLatLong.addElement(actual);
                if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                    controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
                }
            }
            if (!controlador.getModoNavegacion()) {
                long hm = Calendar.getInstance().getTimeInMillis();
                double difer;
                if (hm > horaMilis) {
                    difer = (hm - horaMilis);
                } else {
                    difer = (horaMilis - hm);
                }
                horaMilis = hm;
                difer = difer / 1000; //Paso de ms a s
                double distancia = Utils.Util.distCosineLaw(actual, centro);
                double velocidad = Utils.Util.velocidad(distancia, difer);
                controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), (float) velocidad, (float) distancia * 1000);
            } else {
                controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            }
            centro = actual;
            actualizarTXT();
            BVolver.repaint();
            deseleccionarPOI();
        }
    }//GEN-LAST:event_PMapaMouseDragged

    private void PMapaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMouseClicked
        double[] latlong = dameLatLong(evt.getPoint());
        if (!evt.isMetaDown()) {
            if (controlador.getVectorRuta() != null && controlador.getVectorRuta().size() > 0) {
                BDeshacerMarca.setEnabled(true);
            } else {
                BDeshacerMarca.setEnabled(false);
            }
            if (modoMarcar) {
                double latitud = latlong[0];
                double longitud = latlong[1];
                FicheroDatos infoLinea = new FicheroDatos(latitud, longitud);
                if ((infoLinea.getLatitud() != -1) && (infoLinea.getLongitud() != -1)) {
                    controlador.anadeVectorRuta(CalculosDatos.calcular(infoLinea));
                    rutaLatLong.addElement(infoLinea);
                }
            } else if (anadePOI) {
                latitudClick = latlong[0];
                longitudClick = latlong[1];
                popupAddPOIActionPerformed(null);

            }
        } else {
            latitudClick = latlong[0];
            longitudClick = latlong[1];
            popup.show(evt.getComponent(), evt.getX(), evt.getY());
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        BVolver.repaint();
    }//GEN-LAST:event_PMapaMouseClicked

    private void BDeshacerMarcaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BDeshacerMarcaActionPerformed
        // TODO add your handling code here:
        if (controlador.getVectorRuta().size() > 0) {
            controlador.deshacerMarcarRuta();
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        }
}//GEN-LAST:event_BDeshacerMarcaActionPerformed

    private void BMarcarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BMarcarRutaActionPerformed
        if (modoMarcar == false) {
            BMostrarRuta.setEnabled(true);
            modoMarcar = true;
            rutaLatLong = new Vector();
            controlador.setModoGrabacion(true);
            Image imagenCursor = Toolkit.getDefaultToolkit().getImage(Toolkit.getDefaultToolkit().getClass().getResource("/Archivos/Imagenes/marcador.png"));
            Point hotSpot = new Point(0, 0);
            Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(imagenCursor, hotSpot, "cursorMarcar");
            PMapa.setCursor(cursor);
            BGrabarRuta.setEnabled(false);
            BCargarRuta.setEnabled(false);
            BMarcarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/botonGuardar.png")));
            BMarcarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextGuardar"));
        } else {
            BMostrarRuta.setEnabled(false);
            BMarcarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/marcador.png")));
            BMarcarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextMarcar"));
            modoMarcar = false;
            BGrabarRuta.setEnabled(true);
            BCargarRuta.setEnabled(true);
            BDeshacerMarca.setEnabled(false);
            PMapa.setCursor(defaultCursor);
            if (controlador.guardarRuta(rutaLatLong)) {
                Alertas.exitoGuardarRuta(this);
            } else {
                Alertas.falloGuardarRuta(this);
            }
            reiniciaRuta();
        }
}//GEN-LAST:event_BMarcarRutaActionPerformed

    private void BMostrarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BMostrarRutaActionPerformed
        if (BMostrarRuta.isSelected()) {
            BMostrarRuta.setSelected(true);
            controlador.setMostrarRuta(true);
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        } else {
            BMostrarRuta.setSelected(false);
            controlador.setMostrarRuta(false);
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        }
}//GEN-LAST:event_BMostrarRutaActionPerformed

    private void BCargarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCargarRutaActionPerformed
        try {
            if (controlador.cargarRuta()) {
                Alertas.exitoCargarRuta(this);
                BMostrarRuta.setEnabled(true);
                controlador.setModoGrabacion(true);
            }
        } catch (FileNotFoundException ex) {
            Alertas.falloCargarRuta(this);
        }
}//GEN-LAST:event_BCargarRutaActionPerformed

    private void BGrabarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BGrabarRutaActionPerformed
        if (modoGrabar == false) {
            BMostrarRuta.setEnabled(true);
            rutaLatLong = new Vector();
            modoGrabar = true;
            controlador.setModoGrabacion(true);
            BMarcarRuta.setEnabled(false);
            BDeshacerMarca.setEnabled(false);
            BCargarRuta.setEnabled(false);
            //Guardamos como primera posición la del centro del mapa en ese instante
            centro.setLatitud(controlador.getGeomantes().getCoordenadas().getLatitud());
            centro.setLongitud(controlador.getGeomantes().getCoordenadas().getLongitud());
            controlador.anadeVectorRuta(CalculosDatos.calcular(centro));
            BGrabarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/botonGuardar.png")));
            this.JLPuntosRec.setVisible(true);
            this.LGrabarRuta.setText(LocaleManager.getMessage("grabando"));
            this.LGrabarRuta.setForeground(Color.RED);
        } else {
            BMostrarRuta.setEnabled(false);
            modoGrabar = false;
            if (controlador.guardarRuta(rutaLatLong)) {
                Alertas.exitoGuardarRuta(this);
            } else {
                Alertas.falloGuardarRuta(this);
            }
            reiniciaRuta();
            BMarcarRuta.setEnabled(true);
            BDeshacerMarca.setEnabled(true);
            BCargarRuta.setEnabled(true);
            BBorrarRuta.setEnabled(true);
            BGrabarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/botonGrabarOn.png")));
            this.JLPuntosRec.setVisible(false);
            this.LGrabarRuta.setText(LocaleManager.getMessage("navegacionToolTilTextRec"));
            this.LGrabarRuta.setForeground(Color.BLACK);
        }
}//GEN-LAST:event_BGrabarRutaActionPerformed

    private void BBorrarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BBorrarRutaActionPerformed
        BMarcarRuta.setIcon(new javax.swing.ImageIcon(
                getClass().getResource("/Archivos/Imagenes/marcador.png")));
        BMarcarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextMarcar"));
        modoMarcar = false;
        modoGrabar = false;
        BMostrarRuta.setEnabled(false);
        BGrabarRuta.setEnabled(true);
        BMarcarRuta.setEnabled(true);
        BCargarRuta.setEnabled(true);
        BDeshacerMarca.setEnabled(false);
        PMapa.setCursor(defaultCursor);
        controlador.setModoGrabacion(false);
        reiniciaRuta();
}//GEN-LAST:event_BBorrarRutaActionPerformed

    private void BSatelliteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSatelliteActionPerformed
        controlador.getGeomantes().setMapType("satellite");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
}//GEN-LAST:event_BSatelliteActionPerformed

    private void BRoadmapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BRoadmapActionPerformed
        controlador.getGeomantes().setMapType("roadmap");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
}//GEN-LAST:event_BRoadmapActionPerformed

    private void BHybridActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BHybridActionPerformed
        controlador.getGeomantes().setMapType("hybrid");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
}//GEN-LAST:event_BHybridActionPerformed

    private void BTerrenoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTerrenoActionPerformed
        controlador.getGeomantes().setMapType("terrain");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
}//GEN-LAST:event_BTerrenoActionPerformed

    private void JListPOIValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_JListPOIValueChanged
        if (poi.getListaPOI().size() > 0 && controlador.getMostrarPOI()) {
            String nombre = (String) JListPOI.getSelectedValue();
            if (nombre != null) {
                String tipo = poi.dameTipo(nombre);
                String descripcion = poi.dameDescripcion(nombre);
                poi.setSeleccionado(nombre);
                TXTNombrePOI.setText(nombre);
                TXTTipo.setText(tipo);
                TXTDescripcion.setText(descripcion);
                controlador.getGeomantes().paintBorder(null, PMapa.getGraphics(), 0, 0, 0, 0);
            }
        }
    }//GEN-LAST:event_JListPOIValueChanged

    private void BBorrarPOIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BBorrarPOIActionPerformed
        if (poi.getListaPOI().size() > 0) {
            String nombre = (String) JListPOI.getSelectedValue();
            if (nombre != null) {
                poi.removePOI(nombre);
                modelListPOI.removeElementAt(JListPOI.getSelectedIndex());
                TXTNombrePOI.setText("");
                TXTDescripcion.setText("");
                TXTTipo.setText("");
                controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
                if (modelListPOI.getSize() == 0) {
                    BGuardarPOI.setEnabled(false);
                    BBorrarPOI.setEnabled(false);
                    BMostrarPOI.setEnabled(false);
                    TXTDescripcion.setEditable(false);
                    TXTDescripcion.setFocusable(false);
                }
            }
        }
    }//GEN-LAST:event_BBorrarPOIActionPerformed

    private void popupAddPOIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_popupAddPOIActionPerformed
        NuevoPOI c = new NuevoPOI(this, modelCBPOI, modelListPOI);
        if (c.isOk()) {
            FicheroDatos infoLinea = new FicheroDatos(latitudClick, longitudClick);
            if (poi.addPOI(new ElementoPOI(
                    false,
                    c.getNombre(),
                    c.getDescripcion(),
                    c.getTipo(),
                    latitudClick,
                    longitudClick,
                    (CalculosDatos.calcular(infoLinea))[2],
                    (CalculosDatos.calcular(infoLinea))[3]))) {
                modelListPOI.addElement(c.getNombre());
                controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
                if (modelListPOI.getSize() > 0) {
                    BGuardarPOI.setEnabled(true);
                    BBorrarPOI.setEnabled(true);
                    BMostrarPOI.setEnabled(true);
                }
                anadePOI = false;
                PMapa.setCursor(Cursor.getDefaultCursor());
            }
        }
        anadePOI = false;
        PMapa.setCursor(Cursor.getDefaultCursor());
    }//GEN-LAST:event_popupAddPOIActionPerformed

    private void BAnadirTipoPOIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BAnadirTipoPOIActionPerformed
        if (!modoMarcar) {
            anadePOI = true;
            Image imagenCursor = Toolkit.getDefaultToolkit().getImage(Toolkit.getDefaultToolkit().getClass().getResource("/Archivos/Imagenes/punteroPOI.png"));
            Point hotSpot = new Point(17, 31);
            Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(imagenCursor, hotSpot, "cursorMarcarPOI");
            PMapa.setCursor(cursor);
        }
    }//GEN-LAST:event_BAnadirTipoPOIActionPerformed

    private void BMostrarPOIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BMostrarPOIActionPerformed
        if (BMostrarPOI.isSelected()) {
            BMostrarPOI.setSelected(true);
            controlador.setMostrarPOI(true);
            Component[] aux = JListPOI.getComponents();
            for (int i = 0; i <
                    aux.length; i++) {
                aux[i].setEnabled(true);
            }

            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        } else {
            BMostrarPOI.setSelected(false);
            controlador.setMostrarPOI(false);
            Component[] aux = JListPOI.getComponents();
            for (int i = 0; i <
                    aux.length; i++) {
                aux[i].setEnabled(false);
            }

            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        }
    }//GEN-LAST:event_BMostrarPOIActionPerformed

    private void BGuardarMapasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BGuardarMapasActionPerformed
        controlador.getGeomantes().guardarMapas();
    }//GEN-LAST:event_BGuardarMapasActionPerformed

    private void CBColorRuta1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_CBColorRuta1ItemStateChanged
        if (controlador.getGeomantes() != null) {
            String c = (String) CBColorRuta1.getSelectedItem();
            if (c.equals("Rojo") || c.equals("Red")) {
                controlador.getGeomantes().setColor1(Color.RED);
            }
            if (c.equals("Verde") || c.equals("Green")) {
                controlador.getGeomantes().setColor1(Color.GREEN);
            }
            if (c.equals("Azul") || c.equals("Blue")) {
                controlador.getGeomantes().setColor1(Color.BLUE);
            }
            if (controlador.getGeomantes().getMapaActual() != null) {
                controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            }

        }
    }//GEN-LAST:event_CBColorRuta1ItemStateChanged

    private void CBColorRuta2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_CBColorRuta2ItemStateChanged
        if (controlador.getGeomantes() != null) {
            String c = (String) CBColorRuta2.getSelectedItem();
            if (c.equals("Rojo") || c.equals("Red")) {
                controlador.getGeomantes().setColor2(Color.RED);
            }
            if (c.equals("Verde") || c.equals("Green")) {
                controlador.getGeomantes().setColor2(Color.GREEN);
            }
            if (c.equals("Azul") || c.equals("Blue")) {
                controlador.getGeomantes().setColor2(Color.BLUE);
            }

            if (controlador.getGeomantes().getMapaActual() != null) {
                controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            }

        }
    }//GEN-LAST:event_CBColorRuta2ItemStateChanged

    private void CBColorRuta3ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_CBColorRuta3ItemStateChanged
        if (controlador.getGeomantes() != null) {
            String c = (String) CBColorRuta3.getSelectedItem();
            if (c.equals("Rojo") || c.equals("Red")) {
                controlador.getGeomantes().setColor3(Color.RED);
            }
            if (c.equals("Verde") || c.equals("Green")) {
                controlador.getGeomantes().setColor3(Color.GREEN);
            }
            if (c.equals("Azul") || c.equals("Blue")) {
                controlador.getGeomantes().setColor3(Color.BLUE);
            }

            if (controlador.getGeomantes().getMapaActual() != null) {
                controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            }

        }
    }//GEN-LAST:event_CBColorRuta3ItemStateChanged

    private void BGuardarPOIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BGuardarPOIActionPerformed
        poi.guardarPOI();
    }//GEN-LAST:event_BGuardarPOIActionPerformed

    private void popupCentrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_popupCentrarActionPerformed
        centro = new FicheroDatos(latitudClick, longitudClick);
        controlador.getGeomantes().setCoordenadas(centro);
        controlador.getGeomantes().inicializarGmaps();
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        actualizarTXT();
    }//GEN-LAST:event_popupCentrarActionPerformed

    private void BCargarPOIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCargarPOIActionPerformed
        try {
            if (poi.cargarPOI(modelListPOI)) {
                controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
                if (modelListPOI.getSize() > 0) {
                    BGuardarPOI.setEnabled(true);
                    BBorrarPOI.setEnabled(true);
                    BMostrarPOI.setEnabled(true);
                }

            }
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_BCargarPOIActionPerformed

    private void BDetenerGpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BDetenerGpsActionPerformed
        if (continuarGps) {
            continuarGps = false;
            BDetenerGps.setText("INICIAR GPS");
        } else {
            continuarGps = true;
            BDetenerGps.setText("PARAR GPS");
            activarGps();

        }
    }//GEN-LAST:event_BDetenerGpsActionPerformed

    private void BVolverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BVolverActionPerformed
        BDetenerGpsActionPerformed(evt);
        centro = volverDrag;
        controlador.getGeomantes().setCoordenadas(volverDrag);
        controlador.repaintGeomantes(volverDrag, CalculosDatos.calcular(volverDrag), 0, 0);
        modoDragged = false;
        BVolver.setVisible(false);
        actualizarTXT();
    }//GEN-LAST:event_BVolverActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        try {
            continuarGps = false;
            navegar.join();
            gps.disconnectGPS();
            controlador.reiniciarGeomantes();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_formWindowClosing

    private void BSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSalirActionPerformed
        try {
            if (controlador != null && controlador.getGeomantes() != null) {
                reiniciaRuta();
            }
            continuarGps = false;
            if (navegar != null) {
                if (navegar.isAlive()) {
                    navegar.join();
                }
            }
            gps.disconnectGPS();
            if (controlador != null && controlador.getGeomantes() != null) {
                controlador.reiniciarGeomantes();
            }
            dispose();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
}//GEN-LAST:event_BSalirActionPerformed

    private void TXTDescripcionMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TXTDescripcionMouseExited
        if (poi.getListaPOI().size() > 0) {
            String nombre = (String) JListPOI.getSelectedValue();
            if (nombre != null) {
                String descripcion = poi.dameDescripcion(nombre);
                if (descripcion.compareTo(TXTDescripcion.getText()) != 0) {
                    poi.setDescripcion(nombre, TXTDescripcion.getText());
                }
            }
        }
        TXTDescripcion.setFocusable(false);
        TXTDescripcion.setEditable(false);
    }//GEN-LAST:event_TXTDescripcionMouseExited

    private void TXTDescripcionMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TXTDescripcionMouseEntered
        if (!JListPOI.isSelectionEmpty()) {
            TXTDescripcion.setFocusable(true);
            TXTDescripcion.setEditable(true);
        } else {
            TXTDescripcion.setFocusable(false);
            TXTDescripcion.setEditable(false);
        }
    }//GEN-LAST:event_TXTDescripcionMouseEntered
//
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BAnadirTipoPOI;
    private javax.swing.JButton BBorrarPOI;
    private javax.swing.JButton BBorrarRuta;
    private javax.swing.JButton BCargarMapa;
    private javax.swing.JButton BCargarPOI;
    private javax.swing.JButton BCargarRuta;
    private javax.swing.JButton BDeshacerMarca;
    private javax.swing.JButton BDetenerGps;
    private javax.swing.JButton BGrabarRuta;
    private javax.swing.JButton BGuardarMapas;
    private javax.swing.JButton BGuardarPOI;
    private javax.swing.JButton BHybrid;
    private javax.swing.JButton BMarcarRuta;
    private javax.swing.JCheckBox BMostrarPOI;
    private javax.swing.JCheckBox BMostrarRuta;
    private javax.swing.JButton BRoadmap;
    private javax.swing.JButton BSalir;
    private javax.swing.JButton BSatellite;
    private javax.swing.JButton BTerreno;
    private javax.swing.JButton BVolver;
    private javax.swing.JButton BZoomMas;
    private javax.swing.JButton BZoomMenos;
    private javax.swing.JComboBox CBColorRuta1;
    private javax.swing.JComboBox CBColorRuta2;
    private javax.swing.JComboBox CBColorRuta3;
    private javax.swing.JDesktopPane DPMapa;
    private javax.swing.JLabel JLPuntosRec;
    private javax.swing.JList JListPOI;
    private javax.swing.JTabbedPane JTPTodo;
    private javax.swing.JLabel LColorRuta;
    private javax.swing.JLabel LDescPOI;
    private javax.swing.JLabel LDistancia;
    private javax.swing.JLabel LGrabarRuta;
    private javax.swing.JLabel LHibrido;
    private javax.swing.JLabel LLatitud;
    private javax.swing.JLabel LLongitud;
    private javax.swing.JLabel LNombrePOI;
    private javax.swing.JLabel LPOI;
    private javax.swing.JLabel LPintarRuta;
    private javax.swing.JLabel LRoadmap;
    private javax.swing.JLabel LSatelite;
    private javax.swing.JLabel LTerreno;
    private javax.swing.JLabel LTipoPOI;
    private javax.swing.JLabel LVelocidad;
    private javax.swing.JPanel PDatos;
    private javax.swing.JPanel PMapa;
    private javax.swing.JPanel PTodoMapa;
    private javax.swing.JPanel PTodoPOI;
    private javax.swing.JPanel PTodoRutas;
    private javax.swing.JTextArea TXTDescripcion;
    private javax.swing.JTextField TXTDistancia;
    private javax.swing.JTextField TXTLatitud;
    private javax.swing.JTextField TXTLongitud;
    private javax.swing.JTextField TXTNombrePOI;
    private javax.swing.JTextField TXTTipo;
    private javax.swing.JTextField TXTVelocidad;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JPopupMenu popup;
    private javax.swing.JMenuItem popupAddPOI;
    private javax.swing.JMenuItem popupCancelar;
    private javax.swing.JMenuItem popupCentrar;
    // End of variables declaration//GEN-END:variables

    private void centrarAplicacion() {
        int width = this.getWidth();
        int height = this.getHeight();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width - width) / 2;
        int y = (screen.height - height) / 2;
        setBounds(x, y, width, height);
    }

    private void navegar() {
        mapa.setBorder(controlador.getGeomantes());
        FicheroDatos actual = controlador.getGeomantes().getCoordenadas();
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 0, 0);
    }

    private double dameEscala() {
        if (controlador.getGeomantes().getNivelZoom() == 15) {
            return 3.7037037037037037037037037037037;
        }

        if (controlador.getGeomantes().getNivelZoom() == 16) {
            return 1.8348623853211009174311926605505;
        }

        if (controlador.getGeomantes().getNivelZoom() == 17) {
            return 0.91743119266055045871559633027523;
        }

        if (controlador.getGeomantes().getNivelZoom() == 18) {
            return 0.45871559633027522935779816513761;
        }

        if (controlador.getGeomantes().getNivelZoom() == 19) {
            return 0.22988505747126436781609195402299;
        }

        return 0.91743119266055045871559633027523;
    }

    private void actualizarTXT() {
        TXTLatitud.setText(String.valueOf(centro.getLatitud()));
        TXTLongitud.setText(String.valueOf(centro.getLongitud()));
        TXTVelocidad.setText(String.valueOf(controlador.getGeomantes().getVelocidad()));
        TXTDistancia.setText(String.valueOf(controlador.getGeomantes().getDistancia()));
    }

    private void reiniciaRuta() {
        if (rutaLatLong != null) {
            rutaLatLong = new Vector();
            controlador.iniciaRutaMarcada();
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), zoom, zoom, WIDTH, WIDTH);
        }
    }

    private void cambioIdioma() {
        this.setTitle(LocaleManager.getMessage("navegacionTitulo"));
        this.LLatitud.setText(LocaleManager.getMessage("navegacionLabelLatitud"));
        this.LLongitud.setText(LocaleManager.getMessage("navegacionLabelLongitud"));
        this.LVelocidad.setText(LocaleManager.getMessage("navegacionLabelVelocidad"));
        this.LDistancia.setText(LocaleManager.getMessage("navegacionLabelDistancia"));
        this.BCargarMapa.setText(LocaleManager.getMessage("navegacionCargarMapa"));
        this.BCargarRuta.setText(LocaleManager.getMessage("navegacionCargarRuta"));
        this.BSalir.setText(LocaleManager.getMessage("navegacionSalir"));
        this.BMostrarRuta.setText(LocaleManager.getMessage("navegacionMostrarRuta"));
        this.LRoadmap.setText(LocaleManager.getMessage("navegacionRoadmap"));
        this.LHibrido.setText(LocaleManager.getMessage("navegacionHibrido"));
        this.LSatelite.setText(LocaleManager.getMessage("navegacionSatelite"));
        this.LTerreno.setText(LocaleManager.getMessage("navegacionTerreno"));
        this.PDatos.setBorder(
                javax.swing.BorderFactory.createTitledBorder(
                new javax.swing.border.LineBorder(
                new java.awt.Color(102, 153, 255), 3, true),
                LocaleManager.getMessage("calibracionCoordenadas"),
                javax.swing.border.TitledBorder.CENTER,
                javax.swing.border.TitledBorder.TOP,
                new java.awt.Font("Arial", 1, 14),
                new java.awt.Color(102, 153, 255)));
        this.BGuardarMapas.setText(LocaleManager.getMessage("navegacionGuardarMapa"));
        this.BMostrarPOI.setText(LocaleManager.getMessage("navegacionMostrarPOI"));
        this.BCargarPOI.setText(LocaleManager.getMessage("cargarPOI"));
        this.BGuardarPOI.setText(LocaleManager.getMessage("guardarPOI"));
        this.BBorrarPOI.setText(LocaleManager.getMessage("eliminarPOI"));
        if ((this.JTPTodo.getTitleAt(0).compareTo("Mapa") == 0 ||
                this.JTPTodo.getTitleAt(0).compareTo("Map") == 0)) {
            this.JTPTodo.setTitleAt(0, LocaleManager.getMessage("tituloMapa"));
            this.JTPTodo.setTitleAt(1, LocaleManager.getMessage("tituloRuta"));
            this.JTPTodo.setTitleAt(2, LocaleManager.getMessage("tituloPOI"));
        } else {
            this.JTPTodo.setTitleAt(0, LocaleManager.getMessage("tituloRuta"));
            this.JTPTodo.setTitleAt(1, LocaleManager.getMessage("tituloPOI"));
        }
        this.setColoresRuta();
        this.LColorRuta.setText(LocaleManager.getMessage("coloresDeLaRuta"));
        this.LPintarRuta.setText(LocaleManager.getMessage("navegacionToolTilTextMarcar"));
        this.LGrabarRuta.setText(LocaleManager.getMessage("navegacionToolTilTextRec"));
        this.LDescPOI.setText(LocaleManager.getMessage("descripcion"));
        this.LNombrePOI.setText(LocaleManager.getMessage("nombre"));
        this.LTipoPOI.setText(LocaleManager.getMessage("tipo"));

    }

    private void activarGps() {
        continuarGps = true;
        navegar = new Thread() {

            public void run() {
                try {
                    gps.pollGPS();
                    modoGrabar = false;
                    FicheroDatos actual = gps.getCoordenada();
                    controlador.getGeomantes().setCoordenadas(actual);
                    if (controlador.getModoMapas()) {
                        CalculosDatos.setInfoGoogle(actual, 1899, 1644, "WGS 84");
                    }
                    while (continuarGps) {
                        gps.pollGPS();
                        centro = gps.getCoordenada();
                        controlador.getGeomantes().setCoordenadas(centro);
                        long hm = Calendar.getInstance().getTimeInMillis();
                        double difer;
                        if (hm > horaMilis) {
                            difer = (hm - horaMilis);
                        } else {
                            difer = (horaMilis - hm);
                        }
                        horaMilis = hm;
                        difer = difer / 1000; //Paso de ms a s
                        double distancia = Utils.Util.distCosineLaw(actual, centro);
                        double velocidad = Utils.Util.velocidad(distancia, difer);
                        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), (float) velocidad, (float) distancia * 1000);
                        sleep(intervaloGps * 1000);
                        actualizarTXT();
                        if (controlador.getModoMapas()) {
                            CalculosDatos.setInfoGoogle(actual, 1899, 1644, "WGS 84");
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }

            }
        };
        navegar.start();
    }

    private double[] dameLatLong(Point p) {
        double[] latlong = new double[2];
        double latEsq = CalculosDatos.getLatEsqIzq();
        double lonEsq = CalculosDatos.getLongEsqIzq();

        double gradosX1 = lonEsq;
        double gradosY1 = latEsq;
        double gradosX2 = centro.getLongitud();
        double gradosY2 = centro.getLatitud();

        int pixelX2 = CalculosDatos.calcular(centro)[2];//2803;
        int pixelY2 = CalculosDatos.calcular(centro)[3];//2471;

        FicheroDatos esqIzq = new FicheroDatos(latEsq, lonEsq);
        int pixelX1 = CalculosDatos.calcular(esqIzq)[2];// 0, al principio
        int pixelY1 = CalculosDatos.calcular(esqIzq)[3];// 0

        double restaPix = Math.abs(pixelX2 - pixelX1);
        double restaPixY = Math.abs(pixelY2 - pixelY1);
        double restaGrad = Math.abs(gradosX2 - gradosX1);
        double restaGradY = Math.abs(gradosY2 - gradosY1);

        double metrosporgradoX = Math.abs(Util.LLtoUTM(23, 1, 1).getUTMEasting());
        double metrosporgradoY = Math.abs(Util.LLtoUTM(23, 1, 1).getUTMNorthing());
        double escala = (restaGrad * metrosporgradoX) / restaPix; // metros/pixel
        double escalaY = (restaGradY * metrosporgradoY) / restaPixY; // metros/pixel
        int restaPixelesX = p.x - (mapa.getWidth() / 2);
        int restaPixelesY = p.y - (mapa.getHeight() / 2);
        double restaGradosX = (escala * restaPixelesX) / metrosporgradoX;
        double restaGradosY = (escalaY * restaPixelesY) / metrosporgradoY;
        double latitud = gradosY2 - restaGradosY;
        double longitud = gradosX2 + restaGradosX;
        latlong[0] = latitud;
        latlong[1] = longitud;
        return latlong;
    }

    private void inicializarValores() {
        controlador = Inicio.getControlador();
        configPOI();
        cursorAntiguo = null;
        configMapas();
        configRutas();
    }

    private void configMapas() {
        mapa = PMapa;
        controlador.setDisplayMapa(mapa);
        controlador.setModoNavegacion(false);
        zoom = 17;

        if (controlador.getModoMapas() == true) {//Si modo GoogleMaps
            intervaloGps = 2;
            try {
                controlador.iniciarGeomantes();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            activarGps();
            controlador.getGeomantes().setEscala(dameEscala());
            CalculosDatos.setInfoGoogle(
                    controlador.getGeomantes().getCoordenadas(),
                    1899,
                    1644,
                    "WGS 84",
                    dameEscala());
            horaMilis = Calendar.getInstance().getTimeInMillis();
            navegar();
        } else {//Si modo Mapas Memoria
            intervaloGps = 1;

            BZoomMas.setVisible(false);
            BZoomMenos.setVisible(false);
            JTPTodo.remove(0);
            Component[] c = (Component[]) PTodoRutas.getComponents();
            for (int i = 0; i <
                    c.length; i++) {
                c[i].setEnabled(false);
            }
            JTPTodo.setEnabled(false);
            BCargarMapa.setVisible(true);
        }
        configCoordenadas();
    }

    private void configPOI() {
        poi = new ListadoPOI();
        controlador.setListadoPOI(poi);

        modelListPOI =
                new DefaultListModel();
        for (int i = 0; i <
                poi.getListaPOI().size(); i++) {
            ElementoPOI elem = (ElementoPOI) poi.getListaPOI().elementAt(i);
            modelListPOI.addElement(elem.getNombre());
        }

        JListPOI.setModel(modelListPOI);

        poi.addTipo("Direccion");
        poi.addTipo("Restaurante");
        poi.addTipo("Cafeteria");
        poi.addTipo("Gasolinera");
        poi.addTipo("Hostel");
        poi.addTipo("Parking");
        poi.addTipo("Primeros auxilios");
        poi.addTipo("Servicios");
        poi.addTipo("Otro");
        modelCBPOI =
                new DefaultComboBoxModel();
        for (int i = 0; i <
                poi.getListaTipos().size(); i++) {
            modelCBPOI.addElement(poi.getListaTipos().elementAt(i));
        }

    }

    private void configCoordenadas() {
        //Centro inicial del mapa
        centro = new FicheroDatos();
        centro.setLatitud(controlador.getGeomantes().getCoordenadas().getLatitud());
        centro.setLongitud(controlador.getGeomantes().getCoordenadas().getLongitud());

        //Centro original
        centroOriginal =
                new FicheroDatos();
        centroOriginal.setLatitud(controlador.getGeomantes().getCoordenadas().getLatitud());
        centroOriginal.setLongitud(controlador.getGeomantes().getCoordenadas().getLongitud());

        //Cursor por defecto para cuando dejemos de dibujar
        defaultCursor =
                PMapa.getCursor();

        //Marcamos las coordenadas iniciales en los cuadros de texto
        TXTLatitud.setText(String.valueOf(
                controlador.getGeomantes().getCoordenadas().getLatitud()));
        TXTLongitud.setText(String.valueOf(
                controlador.getGeomantes().getCoordenadas().getLongitud()));
    }

    private void configRutas() {
        // Pintar rutas, por defecto desactivado
        modoMarcar = false;
        modoGrabar =
                false;
        // Exlorar el mapa, por defecto desactivado
        modoDragged =
                false;

        //Colores para la ruta
        setColoresRuta();
        this.JLPuntosRec.setVisible(false);
    }

    private void setColoresRuta() {

        DefaultComboBoxModel colorRuta1 = new DefaultComboBoxModel();
        colorRuta1.addElement(LocaleManager.getMessage("rojo"));
        colorRuta1.addElement(LocaleManager.getMessage("verde"));
        colorRuta1.addElement(LocaleManager.getMessage("azul"));

        DefaultComboBoxModel colorRuta2 = new DefaultComboBoxModel();
        colorRuta2.addElement(LocaleManager.getMessage("rojo"));
        colorRuta2.addElement(LocaleManager.getMessage("verde"));
        colorRuta2.addElement(LocaleManager.getMessage("azul"));

        DefaultComboBoxModel colorRuta3 = new DefaultComboBoxModel();
        colorRuta3.addElement(LocaleManager.getMessage("rojo"));
        colorRuta3.addElement(LocaleManager.getMessage("verde"));
        colorRuta3.addElement(LocaleManager.getMessage("azul"));

        CBColorRuta1.setModel(colorRuta1);
        CBColorRuta2.setModel(colorRuta2);
        CBColorRuta3.setModel(colorRuta3);

        CBColorRuta1.setSelectedIndex(0);
        CBColorRuta2.setSelectedIndex(1);
        CBColorRuta3.setSelectedIndex(0);
    }

    private void deseleccionarPOI() {
        JListPOI.clearSelection();
        TXTDescripcion.setFocusable(false);
    }
}
